"""
@author: 景云鹏
@email: 310491287@qq.com
@date: 2022/6/13
"""
import random
from typing import List


class Solution:

    def __init__(self, nums: List[int]):
        self.nums = nums
        self.nums_dict = {}
        for i, num in enumerate(nums):
            if num not in self.nums_dict:
                self.nums_dict[num] = []
            self.nums_dict[num].append(i)
        self.size = len(self.nums)

    def pick(self, target: int) -> int:
        return random.choice(self.nums_dict[target])
